﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace Webapi.EFCore.IRepository.Base
{
    /// <summary>
    /// 基类仓储接口,其他接口继承该接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IBaseRepository<TEntity> where TEntity : class
    {
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        void Add(TEntity model);

        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        Task<List<TEntity>> GetList();

        /// <summary>
        /// 通过ID(反填)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<TEntity> GetBYID(int id);

        /// <summary>
        /// 异步提交
        /// </summary>
        /// <returns></returns>
        Task<int> SaveChangesAsync();

        /// <summary>
        /// 同步提交
        /// </summary>
        /// <returns></returns>
        int SaveChanges();
    }
}
